package pers.wchen.mybatis.generate.tag;

import pers.wchen.mybatis.generate.model.DataComposeVO;
import pers.wchen.mybatis.generate.model.FileInfoVO;
import pers.wchen.mybatis.generate.util.DateUtil;
import pers.wchen.mybatis.generate.util.SysConstant;

import java.util.Set;

/**
 * @作者： wchen
 * @描述： 
 * @创建时间： 2018/2/13 23:42
 * @版本：Copyright 2018, Inc. All Rights Reserved.
 * @修改信息：
 */
public class ServiceImplTagManager extends AbsTagManager {

    public ServiceImplTagManager(DataComposeVO dataComposeVO, String tableName, String buildFileTag) {
        super(dataComposeVO, tableName, buildFileTag);
    }

    /**
     *  @描述:
     *  @参数： [templateStr]
     *  @返回值： java.lang.String
     *  @创建人: wchen
     *  @创建时间: 2018/2/13
     *  @修改人和其它信息:
     */
    public String replaceFileParam(String templateStr) {

        FileInfoVO fileInfoVO = this.fileInfoMap.get(this.buildFileTag);
        FileInfoVO voFileInfo = this.fileInfoMap.get(SysConstant.KEY_VO);
        FileInfoVO serviceFileInfo = this.fileInfoMap.get(SysConstant.KEY_SERVICE);
        FileInfoVO daoFileInfo = this.fileInfoMap.get(SysConstant.KEY_DAO);
        String replaceTemplateStr = templateStr.replace("&{param.package}", fileInfoVO.getPackageName())
                .replace("&{param.voPackage}", voFileInfo.getPackageName() + "." + voFileInfo.getClassName())
                .replace("&{param.servicePackage}", serviceFileInfo.getPackageName() + "." + serviceFileInfo.getClassName())
                .replace("&{param.daoPackage}", daoFileInfo.getPackageName() + "." + daoFileInfo.getClassName())
                .replace("&{param.tableComponent}", this.tableComponent)
                .replace("&{param.dateTime}", DateUtil.getNowTime())
                .replace("&{param.className}", fileInfoVO.getClassName())
                .replace("&{param.serviceClassName}", serviceFileInfo.getClassName())
                .replace("&{param.serviceLowerClassName}", serviceFileInfo.getLowerClassName())
                .replace("&{param.daoClassName}", daoFileInfo.getClassName())
                .replace("&{param.daoLowerClassName}", daoFileInfo.getLowerClassName())
                .replace("&{param.date}", DateUtil.getNowDate())
                .replace("&{param.voClassName}", voFileInfo.getClassName())
                .replace("&{param.voLowerClassName}", voFileInfo.getLowerClassName())
                ;
//        System.out.println("替换参数后的字符串");
//        System.out.println(replaceTemplateStr);
        return replaceTemplateStr;
    }

    /**
     * @param dealLine
     * @描述: 循环标签处理
     * @参数：
     * @返回值：
     * @创建人: wchen
     * @创建时间: 2018/2/13
     * @修改人和其它信息:
     */
    public String replaceLoopStock(String dealLine, Set<String> exIncludeFields) {
        return null;
    }
}
